import java.util.Scanner;
/** 
 * @author Josh Lear
 * @version 6/14/2014
 * Vector multiplication
 */
public class TJU_2994
{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int numberOfCases = sc.nextInt();
        for(int index = 0; index < numberOfCases; index++){
            int lengthOfArrays = sc.nextInt();
            int[] inputOne = new int[lengthOfArrays];
            int[] inputTwo = new int[lengthOfArrays];
            for(int index2 = 0; index2 < lengthOfArrays; index2++){
                inputOne[index2] = sc.nextInt();
            }
            for(int index3 = 0; index3 < lengthOfArrays; index3++){
                inputTwo[index3] = sc.nextInt();
            }
            int sum = 0;
            for(int index4 = 0; index4 < lengthOfArrays; index4++){
                int product = inputOne[index4] * inputTwo[index4];
                sum = sum + product;
            }
            System.out.println(sum);
        }
        
    }
  
}
